package yj.scms.kafka.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import yj.scms.kafka.sender.KafkaSender;

import java.text.SimpleDateFormat;
import java.util.Date;

@Component
public class ScheduledTasks {

    @Autowired
    private KafkaSender kafkaSender;

    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");

    //5秒钟执行一次 发送一次消息给消费者
    @Scheduled(fixedRate = 5000)
    public void reportCurrentTime() {            //调用消息发送类中的消息发送方法
        kafkaSender.send();
    }

}
